﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>websocket client</title>
    <script type="text/javascript">
        var start = function () {
            var inc = document.getElementById('incomming');
            var wsImpl = window.WebSocket || window.MozWebSocket;
            var txtW = document.getElementById('txtWeight');
            inc.innerHTML += "connecting to server ..<br/>";

            // create a new websocket and connect
            window.ws = new wsImpl('ws://localhost:8181/');

            // when data is comming from the server, this metod is called
            ws.onmessage = function (evt) {
                txtW.value = evt.data;
            };

            // when the connection is established, this method is called
            ws.onopen = function () {
                inc.innerHTML += '.. connection open<br/>';
            };

            // when the connection is closed, this method is called
            ws.onclose = function () {
                inc.innerHTML += '.. connection closed<br/>';
            }
			
			ws.onerror = function (evnt) {
            inc.innerHTML += '.. connection onerror<br/>';
            };

        }
        window.onload = start;
    </script>
</head>
<body>
    <form id="sendForm">
        称重重量   <input id="txtWeight" type="text" />
    </form>
    <pre   id="incomming"></pre>

</body>
</html>
